package com.wxlsoft.excel.convert.handlers;


import org.apache.poi.common.usermodel.HyperlinkType;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.Hyperlink;

import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.handler.context.CellWriteHandlerContext;

public class IndexCellWriteHandler implements CellWriteHandler {

    @Override
    public void afterCellDispose(CellWriteHandlerContext context) {
    	Cell cell = context.getCell();
    	if (cell.getColumnIndex() == 0) {
    		CreationHelper createHelper = context.getWriteSheetHolder()
    				.getSheet()
    				.getWorkbook()
    				.getCreationHelper();
            Hyperlink hyperlink = createHelper.createHyperlink(HyperlinkType.DOCUMENT);
            hyperlink.setAddress(String.format("'%s'!A1", cell.getStringCellValue()));
            cell.setHyperlink(hyperlink);
    	}
    	
    }

}
